home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / qbser21.zip / SIMPLE.BAS < prev   
BASIC Source File  |  1990-10-26  |  4KB  |  133 lines

  1. '   $INCLUDE: 'QBSERIAL.DEC'
  2.  
  3.     DEFINT A-Z
  4.     CLS
  5.    
  6. '   The following lines are used to retrieve the driver copyright
  7.  
  8.     X& = DriverCopyright
  9.     WHILE (PEEK(X&))
  10.         CP$ = CP$ + CHR$(PEEK(X&))
  11.         X& = X& + 1
  12.     WEND
  13.     PRINT CP$
  14.     PRINT
  15.  
  16.     CRLF$ = CHR$(13) + CHR$(10)
  17.     Port = 1
  18.     Length = 8
  19.     Parity = 0
  20.     Rate& = 9600
  21.     HS = 0
  22.  
  23. '   Comm port initilization call format:
  24.  
  25. '   OpenComm Port%, IRQ%, Wordlen%, Parity%, Baudrate&, Handshake%
  26.  
  27.     OpenComm Port, 0, Length, Parity, Rate&, HS
  28.  
  29.     CarrierDetect 1         ' <-- Temporarilly disable UEVENT trip
  30.                             '     to allow data to be transmitted without
  31.                             '     presence of CD signal
  32.  
  33.     ON UEVENT GOSUB CarrierLoss
  34.     UEVENT ON
  35.  
  36. '***************************************************************************
  37. '   Your CODE goes here. Heres an example:
  38.  
  39.     ' To send data out
  40.  
  41.     Transmit "This is transmitted out the serial port." + CRLF$
  42.     Transmit STRING$(25, CHR$(215)) + CRLF$
  43.  
  44.     'To get data from remote (or local) keyboard.
  45.  
  46.     Temp$ = "Enter data: "
  47.     PRINT Temp$
  48.     Transmit Temp$
  49.     Transmit CRLF$
  50.     GOSUB KeyboardInput
  51.     PRINT
  52.     Temp$ = "You entered: " + A$
  53.     PRINT Temp$
  54.     Transmit Temp$
  55.  
  56.     CarrierDetect 1         ' <-- Re-enable carrier detection. Carrier had
  57.                             '     better be true or UEVENT willl occur on
  58.                             '     next Transmit
  59.  
  60.     Transmit CRLF$
  61.  
  62.     DTRcontrol 0            ' <-- Turn OFF the DTR line
  63.     SLEEP 1
  64.     DTRcontrol 1            ' <-- Turn ON the DTR line
  65.     SLEEP 1
  66.     DTRcontrol 0
  67.     SLEEP 1
  68.     DTRcontrol 1
  69.  
  70. '   Your code ends here
  71. '****************************************************************************
  72.  
  73.     'VERY important ending step - if you forget this, you CRASH sometime later.
  74.     'But ONLY restore the vectors if you actually took them, otherwise
  75.     'you'll cause a crash for other reasons.
  76.  
  77. RestoreInt:
  78.  
  79.     CloseComm
  80.     END
  81.  
  82. CarrierLoss:
  83.  
  84.     CLS
  85.     Temp$ = "Loss of Carrier has been detected."
  86.     PRINT Temp$
  87.     GOTO RestoreInt
  88.  
  89.     'Keyboard input scan. Fetches characters from the remote keyboard.
  90.     'Echo's characters as enetered. Returns on carriage return.
  91.  
  92. KeyboardInput:
  93.  
  94.     A$ = ""
  95.     InCount = 0
  96.     ClearInputBuffer
  97.     DO
  98.         DO
  99.             Hit$ = INKEY$
  100.             IF Hit$ <> "" THEN EXIT DO
  101.         LOOP UNTIL DataWaiting
  102.         I$ = ""
  103.         IF Hit$ = "" THEN
  104.             DO WHILE DataWaiting
  105.                 I$ = I$ + CHR$(ReadChar)
  106.             LOOP
  107.         ELSE
  108.             I$ = Hit$
  109.         END IF
  110.         TookIn = LEN(I$)
  111.         IF I$ = CHR$(8) THEN
  112.             IF InCount THEN
  113.                 ' Your code to handle Backspace key goes HERE ********
  114.                 ' Dont forget to send the Backspace sequence out to the
  115.                 ' Com port also with Transmit.
  116.                 ' I did not include it because I did not know how every one
  117.                 ' might handle it. I send a Chr$(8) + Chr$(32) + Chr$(8) to
  118.                 ' both the screen and Comm port.
  119.             END IF
  120.         END IF
  121.         IF I$ = CHR$(13) THEN EXIT DO
  122.         I$ = UCASE$(I$)
  123.         IF I$ > CHR$(&H1F) THEN
  124.             Transmit I$
  125.             PRINT I$;   ' You may need to echo in a different way *******
  126.                         ' Such as if you dont want direct screen writes.
  127.             A$ = A$ + I$
  128.             InCount = InCount + TookIn
  129.         END IF
  130.     LOOP
  131.     RETURN
  132.  
  133.